<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateApksTable extends Migration
{
    private const TABLE = 'apks';

    public function up()
    {
        if (Schema::connection('gameCenter')->hasTable(self::TABLE)) {
            return;
        }
        Schema::connection('gameCenter')->create(self::TABLE, function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('source')->default(0)->comment('渠道ID');
            $table->string('domain_platform')->default('')->comment('平台域名');
            $table->string('base_apk')->default('')->comment('母包');
            $table->string('name')->default('')->comment('安装包名');
            $table->string('path')->default('')->comment('包路径');
            $table->unsignedTinyInteger('status')->default(0)->comment('状态 0初始化 1已生成 2已上传');
            $table->timestamps();
        });
        DB::connection('gameCenter')->statement("ALTER TABLE `tb_".self::TABLE."` comment '客户端APK'");
    }

    public function down()
    {
        Schema::connection('gameCenter')->dropIfExists(self::TABLE);
    }
}
